import Vue from 'vue'
import App from './App'
import { $http } from '@escook/request-miniprogram'
import store from 'store/store.js'

uni.$http = $http

uni.$showMsg = function(title="数据加载出错",duration=1500){
  uni.showToast({
    title,
    duration,
    icon:"none"
  })
}

$http.beforeRequest = function(options){
  uni.showLoading({
    title:"疯狂加载中"
  })
  
  if(options.url.indexOf('/my')!==-1){
    options.header = {
      // 字段的值可以直接从 vuex 中进行获取
      Authorization: store.state.m_user.token,
    }
  }
}

$http.afterRequest = function(options){
  uni.hideLoading()
}

$http.baseUrl="https://api-hmugo-web.itheima.net"

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
	...App,
  store
})
app.$mount()
